package com.sky.runtime;

/**
 * @author : wushikai
 * <p>
 * date : 2022-05-07
 *
 *  https://www.cnblogs.com/luciochn/p/14878160.html  参考
 *
 *
 */
public class ShutdownHookDemo {

    static {
        Runtime.getRuntime().addShutdownHook(new Thread(() -> System.out.println("执行钩子方法...")));
    }

    public static void main(String[] args) throws InterruptedException {
        System.out.println("程序开始启动...");
        Thread.sleep(2000);
        System.out.println("程序即将退出...");
    }


}
